<template>
  <a-card :bordered="false" class="card-area">
    <a-tabs defaultActiveKey="1">
      <a-tab-pane :tab="$t('key.personalInfo')" key="1">
        <stu-info :xh.sync="xh" :checked="false"></stu-info>
      </a-tab-pane>
      <a-tab-pane :tab="$t('key.personalResume')" key="2">
        <stu-resume :xh.sync="xh" :checked="false"/>
      </a-tab-pane>
      <a-tab-pane :tab="$t('key.socialRelations')" key="3">
        <stu-relation :xh.sync="xh" :checked="false"/>
      </a-tab-pane>
    </a-tabs>
    <!-- <a-form :form="form">
    <a-row>
    <a-form-item
  label="审核结果"
  style="width:150px;"
    >
    <a-select style="width:150px;" v-decorator="[
  'statusCode',
    {
      rules: [{ required: true, message: '请选择审核状态!' }],
    }
  ]">
  <a-select-option v-for="i in TYPE0124" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
  </a-select>
  </a-form-item>
  </a-row>
  <a-form-item label="审核备注">
    <a-input type="textarea" style="width:100%;" v-decorator="[
  'explain',
    {
      rules: [{ required: true, message: '请填写审核备注!' }],
    }
  ]" :autosize="{ minRows: 2, maxRows: 10 }"/>
  </a-form-item>
  <a-row style="text-align:left;margin:30px;">
    <a-button type="primary" @click="audit">审核</a-button>
    </a-row>
    </a-form> -->
    <!-- <div>
    审核结果
    <a-select v-model="post.shzt" allowClear style="width:150px;">
    <a-select-option v-for="i in TYPE0124" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
  </a-select>
  </div>
  <div>
  备注<a-input type="textarea" />
    </div>
    <a-row style="text-align:center;margin:30px;">
    <a-button type="primary">审核</a-button>
    </a-row> -->
    <div class="ant-pro-footer-toolbar">
      <a-button style="float: right;margin-top: 10px;" :loading="loading" @click="exportPdf" type="primary">{{
        $t(`button.exportStuCard`) }}
      </a-button>
    </div>
  </a-card>
</template>

<script>
  import stuInfo from '../check/components/stuInfo'
  import stuRelation from '../check/components/stuRelation'
  import stuResume from '../check/components/stuResume'
  import {mapState} from 'vuex'

  export default {
    // props: ['xh'],
    components: {
      stuInfo,
      stuRelation,
      stuResume
    },
    data() {
      return {
        loading: false,
        post: {},
        studentData: {}
      }
    },
    watch: {
      // xh (val) {
      //   if (val) {
      //     this.$api.student.studentInfo(val).then(res => {
      //       this.studentData = res.data
      //     })
      //   }
      // }
    },
    computed: {
      ...mapState({
        user: state => state.account.user,
        TYPE0124: state => state.app['TYPE0124'] // 审核状态
      }),
      xh () {
        return this.$route.query.xh
      }
    },
    beforeCreate() {
      this.form = this.$form.createForm(this)
    },
    created() {
      this.$store.dispatch('app/setDictionary', 'TYPE0124')
      // this.$api.student.studentResume(this.user.xh)
      this.$api.student.studentInfo(this.xh).then(res => {
        this.studentData = res.data
      })
    },
    methods: {
      audit() {
        this.form.validateFields((err, values) => {
          if (err) {
            return
          }
          this.$api.student.supplementCheck(Object.assign({xh: this.xh}, values)).then(res => {
            this.$message.warning('操作成功')
            this.form.resetFields()
            this.$emit('showList')
          })
        })
      },
      exportPdf() {
        let fileName = this.studentData.xm + '_学生学籍卡.pdf'
        this.$downloadPdf('/student/exportXjCard/' + this.xh, {}, fileName)
      }
    }
  }
</script>

<style>

</style>
